import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import axios from "axios";
import {message} from 'ant-design-vue'
import moment from 'moment'
const app = createApp(App)
app.use(store).use(router).use(Antd).mount('#app')
app.config.globalProperties.$moment = moment

axios.defaults.baseURL = '/supply_management'
axios.defaults.withCredentials = true

axios.interceptors.request.use(
    (config)=>{
        return config;
    },
    (error)=>{
        return Promise.reject(error)
    }
)

axios.interceptors.response.use(
    (response)=>{
        // console.log("响应结果：",response)
        // if (response.data.code == 100){
        //     message.error(response.data.message)
        // }
        return response
    },
     (error)=>{
        console.log("错误结果：",error)
        if (error.response.status == 401){
            sessionStorage.clear()
            router.push('/')
            message.error("登录认证已过期，请重新登陆")
        }
        return Promise.reject(error)
    }
)
